// pages/member/profile/profile.js
var api = require('../../../utils/httpUtil.js');
var app = getApp();
Component({
  options: {
    addGlobalClass: true,
  },
  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {
      avatarUrl: '',
      name: '李晓婷',
      gender: '女',
      phone: '13389889090',
      enterPriseName: '上海米特科技',
      address: '上海市普陀区金沙江路'
    }
  },

  lifetimes: {
    // 组件生命周期函数，在组件布局完成后执行，此时可以获取节点信息
    ready: function () {
      this.setData({
        userInfo: app.globalData.userInfo
      })
    }
  },
  methods:{
    onChooseAvatarTap() {
      // 获取隐藏的按钮并触发其点击事件
      const button = this.createSelectorQuery().select('#choose-avatar-btn');
      button.node((res) => {
        res.node.click();
      }).exec();
    },

    onChooseAvatar(e) {
      const {
        avatarUrl
      } = e.detail
      this.setData({
        "userInfo.avatarUrl": avatarUrl,
      })
    },

  }
})
